import os
import tornado.web
import tornado.ioloop
from handler import handlers
from config import PORT, ADDRESS

# 静态文件配置
setting = {
    "template_path": os.path.join(os.path.dirname(__file__), "templates"),
    "static_path": os.path.join(os.path.dirname(__file__), "static"),
    "cookie_secret": "bZJc2sWbQLKos6GkHn/VB9oXwQt8S0R0kRvJ5/xJ89E=",
    "login_url": "/author/login",
    "debug": True,
}
print(setting)


class Application(tornado.web.Application):
    def __init__(self):
        super(Application, self).__init__(handlers=handlers, **setting)


def main():
    app = Application()
    app.listen(port=PORT, address=ADDRESS)
    print("server is run on http://%s:%s" % (ADDRESS, str(PORT)))
    tornado.ioloop.IOLoop().current().start()


if __name__ == '__main__':
    main()
